using System;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using Microsoft.SqlServer.Server;

public class StoredProcedures
{
    [Microsoft.SqlServer.Server.SqlProcedure]
    public static void PriceSum(SqlDouble input, out SqlDouble output)
    {
        using (SqlConnection connection = new SqlConnection("context connection=true"))
        {
            output = input;
            connection.Open();
            SqlCommand command = new SqlCommand("SELECT Qty FROM tbl_Queue", connection);
            SqlDataReader reader = command.ExecuteReader();

            using (reader)
            {
                while (reader.Read())
                {
                    output += reader.GetSqlDouble(0);
                }
            }
            
        }


    }

    [Microsoft.SqlServer.Server.SqlProcedure]
    public static void HelloWorld()
    {
        SqlContext.Pipe.Send("Hello world! It's now " + System.DateTime.Now.ToString() + "\n");
        using (SqlConnection connection = new SqlConnection("context connection=true"))
        {
            connection.Open();
            SqlCommand command = new SqlCommand("SELECT * FROM tbl_Queue", connection);
            SqlDataReader reader = command.ExecuteReader();
            SqlContext.Pipe.Send(reader);
        }
    }
}